#include "common.h"

vector<string> res;
void dfs(TreeNode* root, string s)
{
	if (root == nullptr) return;
	if (root->left == nullptr && root->right == nullptr)
	{
		if (root->val < 0)
			s += '-';
		s += to_string(abs(root->val));
		res.push_back(s);
		return;
	}
	if (root->val < 0)
		s += '-';
	s += to_string(abs(root->val));
	s += "->";
	if (root->left) dfs(root->left, s);
	if (root->right) dfs(root->right, s);
}
vector<string> binaryTreePaths(TreeNode* root)
{
	string s = "";
	dfs(root, s);
	return res;
}